<script setup lang="ts">
import { ref } from 'vue'
import { paidMessage } from '@/constant/dictionaryKey'
import { getJobPayCompany } from '@/api/job'

interface JoinDataDto {
    id?: string
    type: string
    title: string
    content: string
}

const eventChannel = ref()
const fromPay = ref(false)
const joinData = ref<JoinDataDto>({} as JoinDataDto)
const workDetail = ref({})

async function getJoinPayCompany() {
    const res = await getJobPayCompany({
        companyId: joinData.value?.id as string,
    })
    workDetail.value = res
}

async function onGoHome() {
    uni.switchTab({
        url: '/pages/mine/mine',
    })
}

async function onMakePhone() {

}

onLoad((option) => {
    console.log(1111, option)

    option = option || {}
    joinData.value.type = option.type
    joinData.value.title = option.title
    joinData.value.content = option.content
    if (option.id) {
        joinData.value = option as JoinDataDto
        joinData.value.content = paidMessage[option.content as keyof typeof paidMessage] || option.content
        getJoinPayCompany()
    }
})
</script>

<template>
    <NavbarContainer>
        <view class="text-white">
            <image class="mx-auto my-30rpx block h-186rpx w-186rpx"
                   :src="`../../static/images/job-status/${joinData.type === 'success' ? 'complete' : 'error'}.png`" />

            <view class="mb-16rpx text-center text-36rpx font-bold">
                {{ joinData.title }}
            </view>
            <view class="text-center text-28rpx">{{ joinData.content }}</view>
            <view class="mt-30rpx flex items-center justify-center" @click="onGoHome">
                <view class="h-82rpx border border-#ffffff rounded-full border-solid px-20rpx text-center lh-82rpx">返回首页</view>
            </view>
        <!-- <view v-if="joinData.type === 'warn'" class="flex items-center justify-center" @click="onMakePhone">
            <view class="h-82rpx w-150rpx border border-#ffffff rounded-full border-solid text-center lh-82rpx">联系领队</view>
        </view> -->
        </view>
    </NavbarContainer>
</template>

<style scoped></style>

<route lang="json">
{
    "layout": "transparent",
    "style": {
        "navigationBarTextStyle": "white",
        "mp-alipay": {
            "transparentTitle": "always"
        }
    }
}
</route>
